We shouldn't think of the Lord's requirement in the sense of some kind of sinless or flawless perfection on our part.
The word translated "perfect" (τέλειος) here means full-grown or mature.
This word comes from the concept of something coming to pass, a promise being executed, an outcome being reached—things associated with the kinds of ability and accomplishment adults exhibit (as opposed to children).
Its meaning is even clearer in certain other passages of the New Testament, for example:
1 Corinthians 14:20
Brothers, do not be children in your thinking. Be infants in evil, but in your thinking be mature.
Ephesians 4:11–14
And he gave [spiritual leaders] to equip the saints for the work…until we all attain to…mature manhood, to the measure of the stature of the fullness of Christ, so that we may no longer be children….
Hebrews 5:12–14
Though by this time you ought to be teachers, you need someone to teach you again the basic principles of the oracles of God.
You need milk, not solid food, for everyone who lives on milk is unskilled in the word of righteousness, since he is a child.
But solid food is for the mature, for those who have their powers of discernment trained by constant practice to distinguish good from evil.
Maturity is not gained immediately upon obedience to the gospel (compare 1 Timothy 3:6, where a recent convert cannot be an elder in the Lord's church), but maturity nevertheless must be gained!
The parallel account at Luke 6:36 says we must be "merciful, even as [our] Father is merciful," further clarifying Jesus's meaning:
we must be mature enough to accept wrongdoing against ourselves and feel pity for those whose souls are in danger.